package com.poorstu.dao.impl;
import java.util.List;

import com.common.base.dao.impl.BaseDaoImpl;
import com.common.base.model.PaginationSupport;
import com.poorstu.dao.PartTimeDao;
import com.poorstu.model.LeaseMod;
import com.poorstu.model.LoginMod;
import com.poorstu.model.PartTimeMod;
import com.poorstu.model.UserPartTimeMod;

public class PartTimeDaoImpl extends BaseDaoImpl implements PartTimeDao{

	public List<PartTimeMod> selectPartTimeAll() {
		
		try{
			List<PartTimeMod> partTimeList =super.findAll("PartTimeMod");
			return   partTimeList;
		}catch(Exception e)
		{
			e.printStackTrace();
			return null;
		}
		
	}

	public boolean addPartTime(PartTimeMod partTime) {
		try{
			super.save(partTime);
			return true;
		}catch(Exception e){e.printStackTrace();}
		return false;
	}
	
	
	

	public boolean changePartTime(PartTimeMod partTime) {
		try{
		super.saveOrUpdate(partTime);
		return  true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
		
	}
	}
	
	

//	public UserPartTimeMod selectUserPartByJobId(int jobId) {
//		
//		return super.findByHql("from UserPartTimeMod where jobId="+jobId).get(0);
//	}

	public PartTimeMod selectPartTimeById(int jobId) {
		
		 return (PartTimeMod)super.findByHql("from PartTimeMod where jobId="+jobId).get(0);
	}

	public void deletePartTime(List<PartTimeMod> listPartTime) {
		
		super.deleteAll(listPartTime);
		
	}

	public PaginationSupport getPartTimeByPage(String where, String orderField,
			String order, Integer startIndex, Integer pageSize) {
		PaginationSupport ps;
		try{
			ps = super.findByWhereOrderBy(PartTimeMod.class.getName(), where, orderField, order, startIndex, pageSize);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return null;
			
		}
		return ps;
	}
	public PaginationSupport getUserPartTimeByPage(String where,
			String orderField, String order, Integer startIndex,
			Integer pageSize) {
		PaginationSupport ps;
		try{
			ps = super.findByWhereOrderBy(UserPartTimeMod.class.getName(), where, orderField, order, startIndex, pageSize);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return null;
			
		}
		return ps;
	}
	
	
	
	

}
